package com.deer.wms.admin.controller.system;

import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.system.domain.SysUser;
import com.deer.wms.system.domain.SysVersion;
import com.deer.wms.system.service.ISysVersionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 系统版本信息
 */
@Controller
@RequestMapping("system")
public class SysVersionController extends BaseController {
    private String prefix = "system/version";
    @Autowired
    private ISysVersionService sysVersionService;

    @RequiresPermissions("system:version:view")
    @GetMapping("system/version")
    public String version()
    {
        return prefix + "/version";
    }

    @PostMapping("/serverTime")
    @ResponseBody
    public AjaxResult serverTime(){
        Date date = new Date();
        String simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date);

        return AjaxResult.success("sucess!",simpleDateFormat);
    }

    /**
     * 查询系统版本信息列表
     * @param sysVersion
     * @return
     */
//    @RequiresPermissions("system:version:list")
    @RequestMapping("/version/list")
    @ResponseBody
    public TableDataInfo list(SysVersion sysVersion)
    {
        startPage();
        List<SysVersion> list = sysVersionService.findList(sysVersion);
        return getDataTable(list);
    }


    @GetMapping()
    public String update()
    {
        return "redirect:/update" + "/SmartCab.CAB";
    }
}
